﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.ajax({
            url: "../data/system.aspx?method=402",
            async: false,
            success: function (text) {
                if (text == "no")
                    window.location = "../system/error.html";
                else if (text == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                    var tabs = parent.mini.get("mainTabs");
                    var tab1 = tabs.getTab("tab$com");
                    var tab2 = tabs.getTab("tab$401");
                    tab2.enabled = true;
                    tabs.removeTab(tab1);
                    tabs.activeTab(tab2);
                }
            }
        });

        var str = window.location.search;
        var arr = str.split("=");
        var jfno = arr[1].substr(0, arr[1].indexOf('&'));
        var States = [{ id: 0, text: '未审核' }, { id: 1, text: '已审通过' }, { id: 2, text: '已审未通过' }, { id: -1, text: '全部'}];
    </script>
</head>
<body>
    <div class="mini-toolbar" style="border-bottom: 0;">
        <table>
            <tr>
                <td><div id="fairname"></div></td>
                <td>
                    &nbsp;&nbsp;单位名称:
                    <input id="key" class="mini-textbox" style="width:100px" emptytext="关键字"/>
                    &nbsp;&nbsp;类型：
                    <input id="state" class="mini-combobox" style="width: 100px;" data="States" value="-1"/>
                    <a class="mini-button" iconcls="icon-search" plain="true" onclick="search()">查询</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-ok" plain="true" onclick="checkRows(1)">审核通过</a>
                    <a class="mini-button" iconcls="icon-no" plain="true" onclick="checkRows(2)">审核不通过</a>
                    <a class="mini-button" iconcls="icon-remove" plain="true" onclick="delRows()">删除</a>
                    <span class="separator"></span>
                    <a class="mini-button" plain="true" iconcls="icon-excel" onclick="excelRow()">查询结果导出</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowresize="true" url="../data/system.aspx?method=GetJobEnterList" idField="id" multiSelect="true" sizeList="[15,20,50,100]" pageSize="15">
            <div property="columns">
                <div type="checkcolumn" ></div>
                <div cellCls="actionIcons" name="action" width="50px" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>
                <div field="je_name" headerAlign="center" align="center" allowSort="true" renderer="onNameRenderer">单位名称</div>
                <div field="je_contact" headerAlign="center" align="center" >联系人</div>
                <div field="je_tel" headerAlign="center" align="center" >电话</div>
                <div field="je_stay" headerAlign="center" align="center" >住宿</div>
                <div field="je_state" width="80px" headerAlign="center" align="center" allowSort="true" renderer="onStateRenderer">状态</div>
                <div field="je_inserttime" width="80px" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd">报名时间</div>
            </div>
        </div>
    </div>
    <iframe id="exportIFrame" style="display:none;"></iframe>
    <!--导出Excel相关HTML-->
    <form id="excelForm" action="../data/download.aspx?method=ExcelFair" method="post" target="excelIFrame">
        <input type="hidden" name="id" id="jid" />
    </form>
    <iframe id="excelIFrame" name="excelIFrame" style="display:none;"></iframe>
</body>
<script type="text/javascript">
    $.ajaxSetup({
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        complete: function (XMLHttpRequest, textStatus) {
            if (XMLHttpRequest.responseText == "out") {
                var loginWindow = parent.mini.get("loginWindow");
                if (!loginWindow.visible)
                    loginWindow.show();
            }
        }
    });

    mini.parse();

    $.ajax({
        url: "../data/system.aspx?method=GetFairName",
        async: false,
        data: { id: jfno },
        success: function (text) {
            $("#fairname").html("招聘会：<font color='Blue'>" + text + "</font>");
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            ShowMessage("系统提示", "页面加载失败！", 3);
        }
    });

    var grid = mini.get("datagrid1");
    search();

    function search() {
        var key = mini.get("key").getValue();
        var state = mini.get("state").getValue();
        grid.load({ jfno: jfno, key: key, state: state });
        grid.sortBy("je_no", "desc");
    }

    //图标显示
    function onActionRenderer(e) {
        var record = e.record;
        var s = '<span class="icon-word actionspan" title="下载" onclick="editRow(' + record._uid + ')"></span><span class="separator"></span><span class="icon-remove actionspan" title="删除" onclick="delRow(' + record._uid + ')"></span>';
        return s;
    }

    //状态显示
    function onStateRenderer(e) {
        var s;
        if (e.value == 1)
            s = '<font color="Green">已审通过</font>';
        else if (e.value == 2)
            s = '<font color="Red">已审未通过</font>';
        else
            s = '未审核';
        return s;
    }

    function onNameRenderer(e) {
        var record = e.record;
        var s = '<a class="linelink">' + record.je_name + '</a>';
        return s;
    }

    function delRow(row_uid) {
        var row = grid.getRowByUID(row_uid);
        if (row) {
            mini.confirm("确定删除此报名单位吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '删除中，请稍后...' });
                        $.ajax({
                            url: "../data/system.aspx?method=DeleteJobEnter",
                            data: { id: row.je_no },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    win.hide();
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "报名单位删除成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "报名单位删除失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "报名单位删除失败！", 3);
                            }
                        });
                    }
                }
            );
        }
    }

    function delRows() {
        var rows = grid.getSelecteds();
        if (rows.length > 0) {
            mini.confirm("确定删除所选的报名单位吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '删除中，请稍后...' });
                        var ids = "";
                        for (var i = 0; i < rows.length; i++) {
                            ids += rows[i].je_no + ',';
                        }

                        $.ajax({
                            url: "../data/system.aspx?method=DeleteJobEnter",
                            type: "post",
                            data: { id: ids },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "报名单位删除成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "报名单位删除失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "报名单位删除失败！", 3);
                            }
                        });
                    }
                }
            );
        } else
                ShowMessage("系统提示", "请选择需要删除的报名单位！", 2);
    }

    function checkRows(state) {
        var rows = grid.getSelecteds();
        if (rows.length > 0) {
            mini.confirm("确定审核所选报名单位吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '操作中，请稍后...' });
                        var ids = "";
                        for (var i = 0; i < rows.length; i++) {
                            ids += rows[i].je_no + ',';
                        }

                        $.ajax({
                            url: "../data/system.aspx?method=CheckFairEntry",
                            type: "post",
                            data: { id: ids, state: state },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "报名单位审核成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "报名单位审核失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "报名单位审核失败！", 3);
                            }
                        });
                    }
                }
            );
        } else
            ShowMessage("系统提示", "请选择需要审核的报名企业！", 2);
    }

    function editRow(row_uid) {
        var row = grid.getRowByUID(row_uid);
        if (row) {
            window.open(row.je_url);
        }
    }

    function excelRow() {
        mini.confirm("确定导出此招聘会报名情况吗？", "系统提示",
            function (action) {
                if (action == "ok") {
                    $("#jid").val(jfno);
                    $("#excelForm").submit();
                }
            }
        );
    }

    function CloseWindow(action) {
        window.CloseOwnerWindow("ok");
        var tabs = parent.mini.get("mainTabs");
        var tab = tabs.getTab("tab$401");
        tab.enabled = true;
        var iframe = tabs.getTabIFrameEl(tab);
        iframe.contentWindow.search();
        tabs.activeTab(tab);
    }
</script>
</html>
